package com.qx.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qx.mapper.ScDeployMapper;
import com.qx.vo.DeployVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Objects;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qx.pojo.ScDeploy;
import result.PageResult;

@Service
public class ScDeployServiceImpl extends ServiceImpl<ScDeployMapper, ScDeploy> implements ScDeployService{

    @Resource
    private ScDeployMapper scDeployMapper;

    @Override
    public PageResult<ScDeploy> pageSearch(DeployVo deployVo, Integer pageNum, Integer pageSize) {
        Page<ScDeploy> scDeployPage = new Page<>(pageNum,pageSize);
        QueryWrapper<ScDeploy> queryWrapper = new QueryWrapper<>();
        if (Objects.nonNull(deployVo)){
            if (Objects.nonNull(deployVo.getStatus())){
                queryWrapper.like("status",deployVo.getStatus());
            }
            if (Objects.nonNull(deployVo.getName())){
                queryWrapper.like("name",deployVo.getName());
            }
        }
        scDeployPage = scDeployMapper.getPage(scDeployPage,queryWrapper);
        return new PageResult<>(scDeployPage.getTotal(),scDeployPage.getRecords());
    }
}
